###########################################################################
# TSL-BIBLIOTHEK:	AUT_FRM_GUI_Lib
###########################################################################
# $Revision: 1.5 $
# $Author: cbueche $
# $Date: 2001/06/29 18:03:00 $
# $Source: \\\\S7\\ARCHIVE\\CVS_QS/Schueco/Schuecal2000/WR/Scripts/LIB/aut_frm_gui_lib/script,v $
# $NoKeywords: $
###########################################################################
# BESCHREIBUNG: 
#
# PUBLIC INTERFACE:
#	PUBLIC CONSTANTS:
#	PUBLIC FUNCTIONS:
#		FRM_systree_set_item_state_schueco1 ()
#		FRM_systree_set_item_state_schueco2 ()
###########################################################################


#**
#*	A special "wrapper" for SCHUECAL2000 date objects and the obj_type() function.
#*	The function performs a obj_type() on a specified &lt;object&gt; using the value 
#*	from the data table. The special part is the CHK variations that is implemented with
#*  match() insead of smple == comparison.
#* <p>FRM-GUI-TYPE:
#*	data-entry (read/write)
#* <p>TEST DATA FORMAT:
#*	String containing value to be typed or checked.
#* <p>SET-MODE:
#*	The function uses the value from the data table as a second parameter to the
#*	obj_type() function.
#* <p>CHK-MODE:
#*	The function compares the value from the data table with the value returned
#*	by obj_get_text(). Please note that comparison is implemented with match 
#*  (i.e. takes regular expressions as paramers).
#* <p>GEN-MODE:
#*	Uses obj_get_text() to retrieve the content of the &lt;object&gt;. Note that
#*	that no conversion takes place before generating the test data.
#*
#* @param table	(in)	table name
#* @param test	(in)	test name (column)
#* @param object	(in)	GUI-object where actions are to be performed
#* @param suffix	(in)	(optional) as string which ia automatically appended to any
#*	                value.
#* @param force_suffix	(in)(optional) set this to TRUE if you want the &lt;suffix&gt; to
#*	                be typed even if no value present.
#* @return
#*	E_OK:	operation successful
#*	!E_OK:	operation failed
#*/

public function AUT_FRM_date_type ( in table, in test, in object, in suffix, in force_suffix )
{
	switch ( FRM_get_mode( table ) )
	{
	case FRM_SET_MODE:
		return AUT_FRM_SET_date_type( table, test, object, suffix, force_suffix );
	case FRM_CHK_MODE:
		return AUT_FRM_CHK_date_type( table, test, object, suffix );
	case FRM_GEN_MODE:
		return AUT_FRM_GEN_date_type( table, test, object, suffix );
	default:
		return !E_OK;
	}
}

#-------------------------------------------------------------------------------
# FUNCTION: AUT_FRM_SET_date_type
#-------------------------------------------------------------------------------

static function AUT_FRM_SET_date_type ( in table, in test, in object, in suffix, in force_suffix )
{
	auto val = "";
	auto rc, force = FALSE;
	if ( force_suffix*1 != 0 )
		force = TRUE;
	rc = FRM_get_next( table, test, val );
	switch ( rc ) 
	{
	case E_OK:
		break;
	case E_FRM_SKIP:
		if (force)
			break;
		return E_OK;
	default:
		return rc;
	}


	return FRM_rc( calendar_select_date ( object, val & suffix ),
		           "AUT_FRM_SET_date_type",
		           table,
		           test,
		           val );
}

#-------------------------------------------------------------------------------
# FUNCTION: AUT_FRM_CHK_date_type
#-------------------------------------------------------------------------------

static function AUT_FRM_CHK_date_type ( in table, in test, in object, in suffix )
{
	auto val,text, text1,text2,text3;
	auto rc = FRM_get_next( table, test, val );
	switch ( rc ) 
	{
	case E_OK:			break;
	case E_FRM_SKIP:	return E_OK;
	default:			return rc;
	}
	rc= ole_obj_get_info (object, "Day", text2 );
	rc+= ole_obj_get_info (object, "Month", text1 );
	rc+= ole_obj_get_info (object, "Year", text3 );
	text = text1 & "/"& text2 & "/"& text3;
	if ( rc != 0 )
		return rc ;
	rc= match(text, val);
	if ( rc == 0 )
		rc = E_MISMATCH;
	else
		rc = E_OK;
	return FRM_rc( rc,
		           "AUT_FRM_CHK_date_type2",
		           table,
		           test,
		           text & " expected: " & val );
}

#-------------------------------------------------------------------------------
# FUNCTION: AUT_FRM_GEN_date_type
#-------------------------------------------------------------------------------

static function AUT_FRM_GEN_date_type ( in table, in test, in object, in suffix )
{
	auto val = "",rc,text1,text2,text3;;
	rc = obj_exists( object );
	if ( rc == E_OK )
	{
	rc= ole_obj_get_info (object, "Day", text2 );
	rc+= ole_obj_get_info (object, "Month", text1 );
	rc+= ole_obj_get_info (object, "Year", text3 );
	val = text1 & "/"& text2 & "/"& text3;
	}
	FRM_GEN_set( table, test, object, val, rc );
}

#**
#* Performs an action(s) on the table cell(s) according to formatted instruction(s) from the data table.
#*
#* @param table	(in)	table name
#* @param test	(in)	test name (column)
#* @param obj	(in)	object where actions are to be performed
#*/

public function AUT_FRM_tbl_set_data ( in table, in test, in obj, in desc, in list )
{
	auto val, rc;

	do
	{
		rc = FRM_get_next( table, test, val );
		if ( rc == E_OK )
		{
			switch( FRM_get_mode( table ) )
			{
			case FRM_SET_MODE:
				rc = AUT_TBL_cell_action( obj, val, desc, list );
				break;
			case FRM_CHK_MODE:
				rc = AUT_TBL_cell_action( obj, val, desc );		# to be implemented!
				break;
			case FRM_GEN_MODE:
				rc = AUT_TBL_cell_action( obj, val );		# to be implemented!
				break;
			}
		}
	} while ( rc == E_OK );
	if ( rc == E_FRM_SKIP || rc == E_OUT_OF_RANGE )  # empty or EOF
		rc = E_OK;
	return FRM_rc( rc,
		           "AUT_FRM_tbl_cell_action",
		           table,
		           test,
		           val );
}

#**
#*	A standard "wrapper" for menu_select_item() function.
#*	The function performs a menu_select_item() using the value from the data 
#*	table.
#* <p>FRM-GUI-TYPE:
#*	navigation (read-only)
#* <p>TEST DATA FORMAT:
#*	String containing logical name or the index (e.g. #1) of the tab to be 
#*	selected.
#* <p>SET-MODE:
#*	The function reads the value from the data table and uses it as a parameter
#*	to a native menu_select_item() function.
#* <p>CHK-MODE:
#*	Not supported for type: navigation!
#*	There is nothing to be checked with menu_select_item().
#*	Behaves the same as the SET-mode! 
#* <p>GEN-MODE:
#*	Not supported for type: navigation!
#*	Ignores the cell (i.e. skips the cell).
#*
#* @param table	(in)	table name
#* @param test	(in)	test name (column)
#* @param timeout	(in)	(optional) sometimes menues aren't reaady when WR thinks
#*	                they are; use the &lt;timeout&gt; to force the function
#*	                menu_wait_info( object, "enabled", timeout ) to be called
#*	                before the actual menu_select_item() is invoked.
#* @return
#*	E_OK:	operation successful
#*	!E_OK:	operation failed
#*/
public function FRM_menu_select_item1 ( in table, in test, in timeout )
{
	switch ( FRM_get_mode( table ) )
	{
	case FRM_SET_MODE:
	case FRM_CHK_MODE:
		return FRM_SET_menu_select_item1( table, test, timeout );
	case FRM_GEN_MODE:
		return FRM_GEN_menu_select_item1( table, test );
	default:
		return !E_OK;
	}
}

#-------------------------------------------------------------------------------
# FUNCTION: FRM_SET_menu_select_item1
#-------------------------------------------------------------------------------

static function FRM_SET_menu_select_item1 ( in table, in test, in timeout )
{
	auto val;
	auto rc = FRM_get_next( table, test, val );
	switch ( rc ) 
	{
	case E_OK:			break;
	case E_FRM_SKIP:	return E_OK;
	default:			return rc;
	}
	# watch this!
	if ( timeout*1 > 0 )
	{
		rc = EMOS_menu_wait_info1( val, "enabled", 1, timeout*1 );
	} 
	return FRM_rc( EMOS_menu_select_item1( val ),
		           "FRM_SET_menu_select_item1",
		           table,
		           test,
		           val );
}

#-------------------------------------------------------------------------------
# FUNCTION: FRM_CHK_menu_select_item1
#-------------------------------------------------------------------------------

static function FRM_CHK_menu_select_item1 ( in table, in test )
{
	auto val;
	auto rc = FRM_get_next( table, test, val );
	switch ( rc ) 
	{
	case E_FRM_SKIP:	return E_OK;
	default:			return rc;
	}
}

#-------------------------------------------------------------------------------
# FUNCTION: FRM_GEN_menu_select_item1
#-------------------------------------------------------------------------------

static function FRM_GEN_menu_select_item1 ( in table, in test )
{
	FRM_skip( table );
}


#**
#*	A standard "wrapper" for calendar_select_date function
#*	The function performs a 
#*   calendar_select_date ("Anfrage vom:", "10-Apr-2001");.
#*
#*  calendar_select_date ( calendar, date );
#*  calendar	The logical name of the calendar.
#*  The date is recorded in the following format: DD-MMM-YYYY. 
#*  (Numbers as well letters may be used for months).
#*  The calendar_select_date function selects the date 
#*  in the calendar. This is equivalent to clicking the date.
#*
#*
#*  CHK-mode und Gen-Mode noch nicht implementiert
#*  
#*
#* @param table	(in)	table name
#* @param test	(in)	test name (column)
#* @param object	(in)	GUI-object where actions are to be performed
#* @return
#*	E_OK:	operation successful
#*	!E_OK:	operation failed
#*/
public function FRM_calendar_select_date ( in table, in test, in object )
{
	switch ( FRM_get_mode( table ) )
	{
	case FRM_SET_MODE:
		return FRM_SET_calendar_select_date( table, test, object );
	case FRM_CHK_MODE:
		return FRM_CHK_calendar_select_date( table, test, object );
	case FRM_GEN_MODE:
		return FRM_GEN_calendar_select_date( table, test, object );
	default:
		return !E_OK;
	}
}

#-------------------------------------------------------------------------------
# FUNCTION: FRM_SET_calendar_select_date
#-------------------------------------------------------------------------------

static function FRM_SET_calendar_select_date ( in table, in test, in object )
{
	auto val;
	auto rc = FRM_get_next( table, test, val );
	switch ( rc ) 
	{
	case E_OK:			break;
	case E_FRM_SKIP:	return E_OK;
	default:			return rc;
	}
	return FRM_rc( calendar_select_date( object, val ),
		           "FRM_SET_calendar_select_date",
		           table,
		           test,
		           val );
}

#-------------------------------------------------------------------------------
# FUNCTION: FRM_CHK_calendar_select_date  !!!!!!!! noch nicht implementiert
#-------------------------------------------------------------------------------

static function FRM_CHK_calendar_select_date ( in table, in test , in object)
{

	static case_sensitive = TRUE;

	auto val, item, num;
	auto rc = FRM_get_next( table, test, val );
	switch ( rc ) 
	{
	case E_OK:			break;
	case E_FRM_SKIP:	return E_OK;
	default:			return rc;
	}
	
	calendar_get_selected ( object , item, num );
	return FRM_rc(  edit_check_text( object, item, case_sensitive ),
		           "FRM_CHK_calendar_select_date",
		           table,
		           test,
		           val );
}

#-------------------------------------------------------------------------------
# FUNCTION: FRM_GEN_calendar_select_date   !!!!!!!! noch nicht implementiert
#-------------------------------------------------------------------------------

static function FRM_GEN_calendar_select_date ( in table, in test, in object )
{
	#not implemented
	auto val;
	auto rc = FRM_get_next( table, test, val );
}

###########################################################################
# TSL-BIBLIOTHEK:	FRM_GUI_Lib
###########################################################################
